﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;

public partial class template_duankhudothi : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            int pageIndex = ConvertUtility.ToInt32(Request.QueryString["page"]);           
            if (pageIndex > 0)
            {
                bindDA(pageIndex);
                hidPageIndex.Value = pageIndex.ToString();
            }
            else
            {
                bindDA(1);
                hidPageIndex.Value = "1";
            }
            
        }
        catch (Exception ex) { }
    }
    protected void bindDA(int pageIndex)
    {
        int loaiDAID = ConvertUtility.ToInt32(Request.QueryString["loaiDAID"]);
        int quanHuyenID = ConvertUtility.ToInt32(Request.QueryString["quanHuyenID"]);
        if (loaiDAID > 0 && quanHuyenID > 0)
        {
            Category_Info[] lstCat = Category_Info.getCatInDuAn(quanHuyenID, loaiDAID);
            repLoaiBDSc.DataSource = lstCat.Skip((pageIndex - 1) * 18).Take(18);
            repLoaiBDSc.DataBind();

            int totalPage = (int)Math.Ceiling(ConvertUtility.ToDouble(lstCat.Length) / 18);
            pagerbot.Text = ConvertUtility.buildSimplePaging(loaiDAID, totalPage, pageIndex);
        }
    }
}